package com.onesports.intelligent.k12.polarlight.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import com.onesports.framework.kit.common.util.ParamUtils;

/**
 * 考勤状态枚举类
 * @author suyqs
 **/
public enum AttendanceStatusEnum implements IEnum<String> {
    /**
     * 考勤状态枚举类
     */
    NOCHECK("0","待签到"),
    REGISTERED("1","已签到"),
    LEAVE("2","请假"),
    ABSENCE("3","未到");
    private final String type;
    private final String desc;


    AttendanceStatusEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    @Override
    public String getValue() {
        return this.type;
    }

    @JsonValue
    public String getDesc() {
        return this.desc;
    }

    public AttendanceStatusEnum of() {
        return this;
    }

    public static AttendanceStatusEnum of(String desc) {
        for (AttendanceStatusEnum gender : AttendanceStatusEnum.values()) {
            if (ParamUtils.equals(gender.desc, desc)) {
                return gender;
            }
        }
        return null;
    }
    public static AttendanceStatusEnum typeOf(String type) {
        if(AttendanceStatusEnum.NOCHECK.getValue().equals(type)){
            return AttendanceStatusEnum.NOCHECK;
        }else  if(AttendanceStatusEnum.REGISTERED.getValue().equals(type)){
            return AttendanceStatusEnum.REGISTERED;
        }else if(AttendanceStatusEnum.LEAVE.getValue().equals(type)){
            return AttendanceStatusEnum.LEAVE;
        }else if(AttendanceStatusEnum.ABSENCE.getValue().equals(type)){
            return AttendanceStatusEnum.ABSENCE;
        }

        return null;
    }
}
